package com.fire.threadpool.interceptLongTimeThread;

import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;

/**
 * @date 2022/3/24
 * @author zwd
 * @email zwd@hhh.com
 */
public class DelayTaskThreadTest {
	public static void main(String[] args) {
		DelayTaskThread task1 = new DelayTaskThread("thread1", 10000);
		DelayTaskThread task2 = new DelayTaskThread("thread1", 100);
		DelayTaskThread task3 = new DelayTaskThread("thread1", 10);
		DelayQueue<DelayTaskThread> delayQueue = new DelayQueue<>();
		delayQueue.add(task1);
		delayQueue.add(task2);
		delayQueue.add(task3);
		while (true) {
			Delayed take = null;
			try {
				take = delayQueue.take();
			}
			catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println(take);
		}
	}
}
